<!--
 * @Descripttion: (/SensorRealTimeDataTable)
 * @version: (1.0)
 * @Author: (admin)
 * @Date: (2025-09-09)
 * @LastEditors: (admin)
 * @LastEditTime: (2025-09-09)
-->
<template>
  <div class="app-container">
    <!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
    <el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" 
      @submit.native.prevent>
      
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 工具区域 -->

    <!-- 数据区域 -->
    <el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @sort-change="sortChange" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center"/>
      <el-table-column prop="srtdtSysnumber" label="SrtdtSysnumber" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="srtdtInstallloction" label="SrtdtInstallloction" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="srtdtSensorstyle" label="SrtdtSensorstyle" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="srtdtMonitorvalue" label="SrtdtMonitorvalue" align="center" />
      <el-table-column prop="srtdtUnit" label="SrtdtUnit" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="srtdtState" label="SrtdtState" align="center">
        <template slot-scope="scope">
          <dict-tag :options="srtdtStateOptions" :value="scope.row.srtdtState" />
        </template>
      </el-table-column>
      <el-table-column prop="srtdtMindata" label="SrtdtMindata" align="center" />
      <el-table-column prop="srtdtAverdata" label="SrtdtAverdata" align="center" />
      <el-table-column prop="srtdtMaxdata" label="SrtdtMaxdata" align="center" />
      <el-table-column prop="srtdtAlarmcont" label="SrtdtAlarmcont" align="center" />
      <el-table-column prop="srtdtRefreshtime" label="SrtdtRefreshtime" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="srtdtCelectwav1" label="SrtdtCelectwav1" align="center" />
      <el-table-column prop="srtdtCelectwav2" label="SrtdtCelectwav2" align="center" />
      <el-table-column prop="srtdtCelectwav3" label="SrtdtCelectwav3" align="center" />
      <el-table-column prop="srtdtCelectwav4" label="SrtdtCelectwav4" align="center" />
      <el-table-column prop="srtdtBasepoint" label="SrtdtBasepoint" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="siitMininggrouping" label="SiitMininggrouping" align="center" />
      <el-table-column prop="siitMiningface" label="SiitMiningface" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="siitAlarmstatus" label="SiitAlarmstatus" align="center">
        <template slot-scope="scope">
          <dict-tag :options="siitAlarmstatusOptions" :value="scope.row.siitAlarmstatus" />
        </template>
      </el-table-column>
      <el-table-column prop="subStationNum" label="SubStationNum" align="center" :show-overflow-tooltip="true" />
    </el-table>
    <pagination class="mt10" background :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>
<script>
import { 
  listSensorRealTimeDataTable,
  getSensorRealTimeDataTable,
} from '@/api/gb/sensorRealTimeDataTable.js';

export default {
  name: "sensorrealtimedatatable",
  data() {
    return {
      labelWidth: "100px",
      // 选中id数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 遮罩层
      loading: false,
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sort: undefined,
        sortType: undefined,
      },
      // 弹出层标题
      title: "",
      // 操作类型 1、add 2、edit
      opertype: 0,
      // 是否显示弹出层
      open: false,
      // SrtdtState选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
      srtdtStateOptions: [],
      // SiitAlarmstatus选项列表 格式 eg:{ dictLabel: '标签', dictValue: '0'}
      siitAlarmstatusOptions: [],
      // 数据列表
      dataList: [],
      // 总记录数
      total: 0,
    };
  },
  created() {    
    // 列表数据查询
    this.getList();

    var dictParams = [
    ];
  },
  methods: {
    // 查询数据
    getList() {
      this.loading = true;
      listSensorRealTimeDataTable(this.queryParams).then(res => {
         if (res.code == 200) {
           this.dataList = res.data.result;
           this.total = res.data.totalNum;
           this.loading = false;
         }
       })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 重置数据表单
    reset() {
      this.form = {
        id: undefined,
        sysNum: undefined,
        srtdtSysnumber: undefined,
        srtdtInstallloction: undefined,
        srtdtSensorstyle: undefined,
        srtdtMonitorvalue: undefined,
        srtdtUnit: undefined,
        srtdtState: undefined,
        srtdtMindata: undefined,
        srtdtAverdata: undefined,
        srtdtMaxdata: undefined,
        srtdtAlarmcont: undefined,
        srtdtRefreshtime: undefined,
        srtdtCelectwav1: undefined,
        srtdtCelectwav2: undefined,
        srtdtCelectwav3: undefined,
        srtdtCelectwav4: undefined,
        srtdtBasepoint: undefined,
        siitMininggrouping: undefined,
        siitMiningface: undefined,
        siitAlarmstatus: undefined,
        subStationNum: undefined,
        imgaddress: undefined,
        x: undefined,
        y: undefined,
      };
      this.resetForm("form");
    },
    // 重置查询操作
    resetQuery() {
      this.timeRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1
      this.multiple = !selection.length;
    },
     // 自定义排序
    sortChange(column) {
      if (column.prop == null || column.order == null) {
        this.queryParams.sort = undefined;
        this.queryParams.sortType = undefined;
      } else {
        this.queryParams.sort = column.prop;
        this.queryParams.sortType = column.order;
      }

      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加";
      this.opertype = 1;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const Ids = row.id || this.ids;

      this.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项？')
        .then(function () {
          return delSensorRealTimeDataTable(Ids);
        })
        .then(() => {
          this.handleQuery();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getSensorRealTimeDataTable(id).then((res) => {
        const { code, data } = res;
        if (code == 200) {
          this.open = true;
          this.title = "修改数据";
          this.opertype = 2;

          this.form = {
            ...data,
          };
        }
      });
    },
    //图片上传成功方法
    handleUploadSuccess(column, filelist) {
      this.form[column] = filelist;
    },
    // SrtdtState字典翻译
    srtdtStateFormat(row, column) {
      return this.selectDictLabel(this.srtdtStateOptions, row.srtdtState);
    },
    // SiitAlarmstatus字典翻译
    siitAlarmstatusFormat(row, column) {
      return this.selectDictLabel(this.siitAlarmstatusOptions, row.siitAlarmstatus);
    },

  },
};
</script>